<?php
namespace Api\Controller;
use Think\Controller;
class TaskController extends CommonController {

    //检测VIP是否过期（每天00:20）
    public function vipExpireCheck() {

        $where = "status = " .C("USER_STATUS.VIP"). " AND DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i') >= DATE_FORMAT(vip_end_time,'%Y-%m-%d %H:%i')";

        $userList = $this->userModel->where($where)->select();

        if(!isNullOrEmpty($userList)) {

            $userIds = array_column($userList,'user_id');

            //取消用户VIP身份
            $userMap['user_id'] = array('in',$userIds);

            $userData['status'] = C("USER_STATUS.AUTH");

            $this->userModel->where($userMap)->save($userData);

            //删除用户红娘关系
            $userSoubretteRelationshipMap['user_id'] = array('in',$userIds);
            $this->userSoubretteRelationshipModel->where($userSoubretteRelationshipMap)->delete();

        }

    }
}